#ifndef MYPROFILE_H
#define MYPROFILE_H
#include <QString>
class QTextEdit;

enum class ProfileType {
  TRACE,
  UP,
  DOWN,
  WARNING,
  ERROR,

};

class MyProfile {
public:
  MyProfile(QTextEdit *te);

  void clear();

  void append(ProfileType type, const QString &info, const QString &str);

  void save(const QString &fileName);

private:
  QTextEdit *_te;
};

#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) ||    \
    (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__)
#define SGH_FUNC_SIG __PRETTY_FUNCTION__
#elif defined(__DMC__) && (__DMC__ >= 0x810)
#define SGH_FUNC_SIG __PRETTY_FUNCTION__
#elif (defined(__FUNCSIG__) || (_MSC_VER))
#define SGH_FUNC_SIG __FUNCSIG__
#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) ||              \
    (defined(__IBMCPP__) && (__IBMCPP__ >= 500))
#define SGH_FUNC_SIG __FUNCTION__
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
#define SGH_FUNC_SIG __FUNC__
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
#define SGH_FUNC_SIG __func__
#elif defined(__cplusplus) && (__cplusplus >= 201103)
#define SGH_FUNC_SIG __func__
#else
#define SGH_FUNC_SIG "SGH_FUNC_SIG unknown!"
#endif

#ifndef MYPROFILE_INIT
#define MYPROFILE_INIT(te) singleton<MyProfile>::getInstance(te)
#endif // !MYPROFILE_INIT

#ifndef MYPROFILE_CLEAR
#define MYPROFILE_CLEAR() singleton<MyProfile>::getInstance(nullptr)->clear()
#endif // !MYPROFILE_CLEAR

#ifndef MYPROFILE_SCOPE
#define MYPROFILE_SCOPE(type, info, str)                                       \
  singleton<MyProfile>::getInstance(nullptr)->append(type, info, str)
#endif // !MYPROFILE_SCOPE

#ifndef MYPROFILE
#define MYPROFILE(type, str) MYPROFILE_SCOPE(type, __func__, str)
#endif // !MYPROFILE

#ifndef MYPROFILE_SAVE
#define MYPROFILE_SAVE(fileName)                                               \
  singleton<MyProfile>::getInstance(nullptr)->save(fileName)
#endif // !MYPROFILE_SAVE

#endif // MYPROFILE_H
